#!/usr/bin/perl
#

%uniqPosTags = ();
$lineNum = 1;
while($line=<STDIN>) {
	chomp($line);
	$line=~s/^([^\s]*)\s*=\s*//g;
	$word = $1;
	@entries = split(/#/,$line);
	my $afEntry = "";
	foreach $entry (@entries) {
		@fields = split(/\s+/,$entry);
		my $root = shift @fields;
		my $pos = shift @fields;
		$uniqPosTags{$pos}++;

		my $rest = join(' ',@fields);
		my $num = "sg";
		my $person = "3";
		if($rest=~/([0-9]+)((sg)|(pl))/) {
			$num = $2;
			$person = $1;
		}

		$afEntry.="<fs af='$root,$pos,x,$person,$num,,,'>|";
	}
	$afEntry=~s/[|]$//g;
	print $lineNum."\t".$word."\t".$afEntry."\n";
	$lineNum++;
}

foreach $pos (sort {$uniqPosTags{$b}<=>$uniqPosTags{$a}} keys %uniqPosTags) {
	print STDERR $pos." ".$uniqPosTags{$pos}."\n";
}
